1. /* slfdivml.cpp by K.Tsuru */
  2. // function ID = 211 DRADIX, BRADIX
  3. /*************************************************************************
  4. SLong and SInteger classes
  5. It provides a sub-function for the multiplication between multi-precision
  6. integers.
  7. *************************************************************************/
  8. #ifndef SN_H
  9. #include "sn.h"
  10. #endif
  11. /*
  12. Let q=n.figure.size(), U = R^q
  13. m=M[d-1]*U^(d-1)+....M[1]*U+M[0].
  14. m*n=(M[d-1]*n)*U^(d-1)+....(M[1]*n)*U+M[0]*n.
  15. */
  16. SLong DivLLMult(const SLong& m, const SLong& n){
  17. uint mh = m.aHead+1, nh = n.aHead+1;
  18. uint mf = ceilpow2(mh), nf = ceilpow2(nh), div = mf/nf;
  19. #ifndef NDEBUG
  20. assert(div > 1);
  21. #endif
  22. if(nh < m.FFTMinSize()) return NLLMult(m, n);
  23. SLong result, p;
  24. SLong* w = new SLong[div];
  25. uint j, pos;
  26. for(j = 0, pos = 0; j < div; j++, pos += nf){
  27. result.SLCutOut(w[j], m, pos, nf);
  28. }
  29. result = w[0]*n;
  30. for(j = 1; j < div; j++){
  31. p = n*w[j];
  32. p.ShiftArray(int(j*nf));
  33. result = LLAdd(result, p); // result += p;
  34. }
  35. delete[] w;
  36. result.SetSign(m.Sign()*n.Sign());
  37. return result;
  38. }

slfdivml.cpp : last modifiled at 2014/05/07 10:14:31(1,103 bytes)
created at 2017/10/07 10:26:50
The creation time of this html file is 2017/11/09 14:52:03 (Thu Nov 09 14:52:03 2017).